package com.tianqu.tms.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tianqu.tms.core.base.TmsEntity;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.dao.CommercialVehicleDao;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dto.CommercialVehicleDto;

/**
 * 
 * 商用车款式
 * 
 * @author Administrator
 * 
 */
public class CommercialStyle extends TmsEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -690853848248101758L;
	private String id;
	private String vendorName;
	private String brandName;
	private String modelName;
	private String vendorId;
	private String brandId;
	private String vendorFirstChar;
	private String brandFirstChar;
	private String vendorPy;
	private String brandPy;
	private String modelPy;
	private String country;
	private String enImage;
	private String znImage;
	private String search;
	private int price;
	private String ps;
	private String drive;
	private int displacement;
	private String publicModel;
	private String seating;
	private String wide;
	private int fuelType;
	private int cabType;
	private int type;
	private int carUse;
	private int vId;
	private String bId;

	/**
	 * 实例化codes表
	 * 
	 * @return
	 */
	private static CommercialStyle instance;

	List<CommercialStyle> codes = null;

	/**
	 * 加载Codes
	 * 
	 * @return
	 * @throws TmsDaoException
	 */
	public static CommercialStyle getInstance() throws TmsDaoException {
		if (null == instance) {
			instance = new CommercialStyle();
			instance.init();
		}
		return instance;
	}

	/**
	 * 实例化Code
	 * 
	 * @throws TmsDaoException
	 */
	public void init() throws TmsDaoException {
		codes = new ArrayList<CommercialStyle>();
		setCodes();
	}

	/**
	 * 获取Codes信息存在静态codes中
	 * 
	 * @throws TmsDaoException
	 */
	public void setCodes() throws TmsDaoException {
		CommercialVehicleDao dao = (CommercialVehicleDao) TmsDao.getInstance(TmsDao.TMS_COMMERCIAL_VEHICLE);
		List<CommercialVehicleDto> list = dao.findAllCarStyleInfo();
		for (int i = 0; i < list.size(); i++) {
			CommercialVehicleDto dto = (CommercialVehicleDto) list.get(i);
			CommercialStyle entity = new CommercialStyle();
			entity.setBrandId(dto.getBrandId());
			entity.setId(dto.getId());
			entity.setModelName(dto.getModelName());
//			entity.setCarStylePinYin(dto.getCarStylePinYin());
//			entity.setGearbox(dto.getGearbox());
//			entity.setdisplacement(dto.getDisplacement());
//			entity.setCarType(dto.getCarType());
			codes.add(entity);
		}
	}

	/**
	 * 根据车辆车系ID获取款式下拉列表
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List getAllCarStyleInfo(String brandId) {
		List list = new ArrayList();
		Map map = null;
		for (int i = 0; i < codes.size(); i++) {
			CommercialStyle entity = codes.get(i);
			if (entity.getBrandId().equals(brandId)) {
				map = new HashMap();
				map.put("carStyleId", entity.getId());
				map.put("carStyleName", entity.getModelName());
				list.add(map);
			}
		}

		return list;
	}

	/**
	 * 根据ID获取排量
	 * 
	 * @return
	 */
//	public float getExhaustByCarStyleId(String carStyleId) {
//		for (int i = 0; i < codes.size(); i++) {
//			CommercialStyle entity = (CommercialStyle) codes.get(i);
//			if (entity.getId().equals(carStyleId)) {
//				return entity.getDisplacement();
//			}
//		}
//		return 0;
//	}

	/**
	 * 根据款式ID获取变速箱code 这个返回-1
	 * 
	 * @return
	 */
//	public int getGearboxByCarStyleId(String carStyleId) {
//		for (int i = 0; i < codes.size(); i++) {
//			CommercialStyle entity = (CommercialStyle) codes.get(i);
//			if (entity.getId().equals(carStyleId)) {
//				return entity.getGearbox();
//			}
//		}
//		return -1;
//	}

	/**
	 * 根据款式ID获取车辆名称
	 * 
	 * @return
	 */

	public String getCarStyleRealNameById(String carStyleId) {
		for (int i = 0; i < codes.size(); i++) {
			CommercialStyle entity = (CommercialStyle) codes.get(i);
			if (entity.getId().equals(carStyleId)) {
				return entity.getModelName();
			}
		}
		return "";
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getVendorName() {
		return vendorName;
	}

	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	public String getBrandName() {
		return brandName;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public String getVendorId() {
		return vendorId;
	}

	public void setVendorId(String vendorId) {
		this.vendorId = vendorId;
	}

	public String getBrandId() {
		return brandId;
	}

	public void setBrandId(String brandId) {
		this.brandId = brandId;
	}

	public String getVendorFirstChar() {
		return vendorFirstChar;
	}

	public void setVendorFirstChar(String vendorFirstChar) {
		this.vendorFirstChar = vendorFirstChar;
	}

	public String getBrandFirstChar() {
		return brandFirstChar;
	}

	public void setBrandFirstChar(String brandFirstChar) {
		this.brandFirstChar = brandFirstChar;
	}

	public String getVendorPy() {
		return vendorPy;
	}

	public void setVendorPy(String vendorPy) {
		this.vendorPy = vendorPy;
	}

	public String getBrandPy() {
		return brandPy;
	}

	public void setBrandPy(String brandPy) {
		this.brandPy = brandPy;
	}

	public String getModelPy() {
		return modelPy;
	}

	public void setModelPy(String modelPy) {
		this.modelPy = modelPy;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getEnImage() {
		return enImage;
	}

	public void setEnImage(String enImage) {
		this.enImage = enImage;
	}

	public String getZnImage() {
		return znImage;
	}

	public void setZnImage(String znImage) {
		this.znImage = znImage;
	}

	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getPs() {
		return ps;
	}

	public void setPs(String ps) {
		this.ps = ps;
	}

	public String getDrive() {
		return drive;
	}

	public void setDrive(String drive) {
		this.drive = drive;
	}

	public int getDisplacement() {
		return displacement;
	}

	public void setDisplacement(int displacement) {
		this.displacement = displacement;
	}

	public String getPublicModel() {
		return publicModel;
	}

	public void setPublicModel(String publicModel) {
		this.publicModel = publicModel;
	}

	public String getSeating() {
		return seating;
	}

	public void setSeating(String seating) {
		this.seating = seating;
	}

	public String getWide() {
		return wide;
	}

	public void setWide(String wide) {
		this.wide = wide;
	}

	public int getFuelType() {
		return fuelType;
	}

	public void setFuelType(int fuelType) {
		this.fuelType = fuelType;
	}

	public int getCabType() {
		return cabType;
	}

	public void setCabType(int cabType) {
		this.cabType = cabType;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getCarUse() {
		return carUse;
	}

	public void setCarUse(int carUse) {
		this.carUse = carUse;
	}

	public int getvId() {
		return vId;
	}

	public void setvId(int vId) {
		this.vId = vId;
	}

	public String getbId() {
		return bId;
	}

	public void setbId(String bId) {
		this.bId = bId;
	}

	public List<CommercialStyle> getCodes() {
		return codes;
	}

	public void setCodes(List<CommercialStyle> codes) {
		this.codes = codes;
	}

	@Override
	public void save() throws TmsDaoException, TmsException {
	}

}
